#!/usr/bin/env python

import pygtk
pygtk.require("2.0")
import gtk

class TrayIcon:
    _ticon = None
    _mainWindow = None
    
    def __init__(self, mainWindow):
        self._mainWindow = mainWindow
    
    def show(self):
        ticon = gtk.StatusIcon()        
        ticon.set_visible(True)
        ticon.set_tooltip("Test")
        ticon.set_from_stock(gtk.STOCK_EXECUTE)
        ticon.connect("activate", self.activate)
        ticon.connect("popup_menu", self.popup) 
        
        self._ticon = ticon
    
    def activate( self, widget, data=None): 
        visible = self._mainWindow._window.get_property("visible")
        if visible:
            self._mainWindow.hide()
        else:
            rect = self._ticon.get_geometry()[1]
            self._mainWindow.show(rect[0], rect[1])
        
    def popup(self, button, widget, data=None):
        pass
    